const state = {
  orderData: [],
  orderDataCount: 0
}

const mutations = {
  GET_ORDER_DATA: (state, data) => {
    state.orderData = data
  },
  GET_ORDER_DATA_COUNT: (state, data) => {
    state.orderDataCount = data
  }
}

const actions = {
  async getOrderData({ commit }, playload) {
    let data = {}
    let newData = []
    if (Object.keys(playload).length > 0) {
      data = playload
    }
    for (let i = 0; i < 6; i++) {
      newData = [...newData, {
        id: i + 1,
        host: 'http://carimg.91kym.com',
        ordernum: '2000578460',
        cid: '010',
        number: '苏D-A2929',
        brand: '阿斯顿马丁',
        name: '杨琴',
        tel: '13775237256',
        ordertime: '2019-04-24 14:58:00',
        picktime: '2019-04-24 14:58:00',
        returntime: '2019-04-24 14:58:00',
        state: 0,
        pickaddress: '江苏常州',
        returnaddress: '江苏常州',
        delivery: '1',
        rentalstate: '1',
        method: '1',
        cost: 5000,
        deposit: 2000,
        sumcost: 7000,
        ctype: '超豪华轿跑车',
        color: '黑色',
        pid: '010',
        document: '身份证',
        dnumber: '320402199106292929',
        countdown: '10天',
        img1: '',
        img2: '',
        img3: '',
        mileage: '',
        des1: '',
        des2: '',
        des3: '',
        carMileage: '',
        img4: '',
        img5: '',
        img6: '',
        des4: '',
        des5: '',
        des6: '',
        withdrawal: '',
        annex: '',
        annexDes: '',
        gps: ''
      }]
    }
    commit('GET_ORDER_DATA', newData)
    commit('GET_ORDER_DATA_COUNT', newData.length)
    // const resp = await getCustomerTable(data)
    // resp.data.data.rows.map((item) => {
    //   if ((item.state === 3 || item.state === 4 || item.state === 5 || item.state === 6) && item.state0 === 0) {
    //     newData = [...newData, {
    //       id: item.id,
    //       uid: item.uid,
    //       ctime: item.ctime,
    //       uname: item.uname,
    //       tel: item.tel,
    //       coludname: item.coludname,
    //       coludtel: item.coludtel,
    //       mname: item.mname,
    //       pname: item.pname,
    //       puid: item.puid,
    //       appointime: item.appointime,
    //       state: item.state.toString(),
    //       comdate: item.comdate,
    //       tname: item.tname,
    //       gid: item.gid,
    //       gname: item.gname,
    //       orderdate: item.orderdate,
    //       cprice: item.cprice,
    //       commission: item.commission,
    //       state0: item.state0,
    //       ttype: item.ttype ? item.ttype.toString() : '',
    //       remarks: item.remarks,
    //       perrate: item.perrate,
    //       permoney: item.permoney,
    //       budget: item.budget,
    //       difftime: item.difftime,
    //       lostdate: item.lostdate,
    //       sex: item.sex,
    //       age: item.age || item.age === 0 ? item.age.toString() : '',
    //       want: item.want || item.want === 0 ? item.want.toString() : ''
    //     }]
    //   }
    // })
    // commit(ARRIVE_LIST, newData)
    // commit(ARRIVE_DATA_COUNT, resp.data.data.total)
    // if (newData.length < rootState.arrive.arrivePageSize) {
    //   commit(ARRIVE_HISTORY_DATA, newData)
    // } else {
    //   commit(ARRIVE_HISTORY_DATA, newData.slice(0, rootState.arrive.arrivePageSize))
    // }
    // return resp
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
